package com.logistics.delivery.entity.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.logistics.delivery.entity.model.DeliveryContainerSave;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 配送托盘
 * </p>
 *
 * @author sun.yang
 * @since 2024-06-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("lgs_delivery_container")
public class DeliveryContainer implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 配送单
     */
    private String delivery;

    /**
     * 拣配单
     */
    private String pick;

    /**
     * 托盘
     */
    private String container;

    /**
     * 托盘层级
     */
    private Integer containerLevel;

    /**
     * 是否是空托盘（0:非空，1:空托）
     */
    private Boolean isEmpty;

    /**
     * 站点位置
     */
    @TableField(select = false)
    private String station;

    /**
     * 创建人组织编码
     */
    private String createOrgCode;

    /**
     * 创建人部门编码
     */
    private String createDepCode;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改人
     */
    private String updater;

    /**
     * 修改时间
     */
    private Date updateTime;

    public static DeliveryContainer build(DeliveryContainerSave edit) {
        DeliveryContainer deliveryContainer = new DeliveryContainer();
        deliveryContainer.setId(edit.getId());
        deliveryContainer.setDelivery(edit.getDelivery());
        deliveryContainer.setPick(edit.getPick());
        deliveryContainer.setContainer(edit.getContainer());
        deliveryContainer.setContainerLevel(edit.getContainerLevel());
        deliveryContainer.setIsEmpty(edit.getIsEmpty());
        deliveryContainer.setCreateDepCode(edit.getCreateDepCode());
        deliveryContainer.setCreateOrgCode(edit.getCreateOrgCode());
        deliveryContainer.setCreator(edit.getCreator());
        deliveryContainer.setCreateTime(DateUtils.stringToDateFormat(edit.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
        deliveryContainer.setUpdater(edit.getUpdater());
        deliveryContainer.setUpdateTime(DateUtils.stringToDateFormat(edit.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
        return deliveryContainer;
    }
}
